#ifndef OWIDGET_H
#define OWIDGET_H
#include <directfb.h>
#include <fusion/fusion.h>
#include <fusion/shmalloc.h>
#include <fusion/call.h>
#include <fusion/arena.h>

#include <OType.h>

#include <OEvent.h>
#include <OObject.h>


class OWidget:public OEvent,public OObject{
	public:
		OWidget(OWidget *parent=NULL);
		OWidget(IDirectFB	*d);
		~OWidget();

		void SetBackgroundColor(u8 r,u8 g,u8 b,u8 a);
		void SetPosition(u16 x,u16 y);
		void SetSize(u16 width,u16 height);
		void SetOpacity(u8 opacity);
		void SetColor(u8 r,u8 g,u8 b,u8 a);
		void Update();

		void Invalid();

		int AddChild(OWidget *);

		OWidget *GetChild(int);
		int GetChildCount();
		int GetSizeWidth();
		int GetSizeHeight();
		int GetPosX();
		int GetPosY();

		void Hide();
		void Show();

		OWidget *GetParent();

		bool IsVisiable();

	private:
		vector<OWidget *> ChildList;

		virtual void Handler(){}
		virtual void Invoke(){}
		
	protected:		
		IDirectFB               *dfb;
		IDirectFBDisplayLayer   *layer;
		IDirectFBWindow			*window;
		IDirectFBSurface		*surface;
		DFBWindowDescription	widgetdesc;

		u16		pX,pY,pHeight,pWidth,pOpacity;
		u16		pAbsX,pAbsY;
		bool	pVisiable;
		OWidget *pParent;

		void SetStacking();
};
#endif
